

    public static class StringExtend 
    {
        /// <summary>
        /// 这个也许不能保证所有计算机都一样
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static int GetStableHashCode(this string text)
        {
            unchecked
            {
                int hash = 23;
                foreach (char c in text)
                    hash = hash * 31 + c;
                return hash;
            }
        }
        public static string ToWarning(this string logInfo)
        {
            return string.Format("<color=#FFFF00>{0}</color>", (object)logInfo);
        }
        public static string ToGreen(this string logInfo)
        {
            return string.Format("<color=#00FD0D>{0}</color>", (object)logInfo);
        }
        public static bool IsEmail(this string str)
        {
            string expression =
                @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
            return System.Text.RegularExpressions.Regex.IsMatch(str, expression,
                System.Text.RegularExpressions.RegexOptions.Compiled);
        }
        public static bool HaveTeShu(this string str)
        {
            string s = System.Text.RegularExpressions.Regex.Replace(str, "[\\u4e00-\\u9FA5A-Za-z0-9]", "",
                System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            return s.Length > 0;
        }

        public static bool HaveEnglish_B(this string str)
        {
            string s = str;
            string result= System.Text.RegularExpressions. Regex.Replace(str, "[\\u4e00-\\u9FA5A-Z]","");
            return result.Length < s.Length;
        }
        public static bool HaveEnglish_s(this string str)
        {
            string s = str;
            string result= System.Text.RegularExpressions. Regex.Replace(str, "[\\u4e00-\\u9FA5a-z]","");
            return result.Length < s.Length;
        }

        public static bool HaveNum(this string str)
        {
            string s = str;
            string result= System.Text.RegularExpressions. Regex.Replace(str, "[\\u4e00-\\u9FA50-9]","");
            return result.Length < s.Length;
        }

        public static string ReplaceN(this string str)
        {
            return str.Replace("\\n", "\n");
        }
    }

